package com.wolfking.converter.transform.extend;

import com.wolfking.converter.transform.AbstractExtendTransform;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

public class BankNameTransform extends AbstractExtendTransform<String> {
    @Override
    public String transform(Object value) throws Exception {
        if (Objects.isNull(value)) {
            return "";
        }
        String s = value.toString();
        if (StringUtils.isBlank(s)) {
            return s;
        }

        try {
            s = new DictTransform("bankCode").transform(s);
        } catch (Exception e) {
        }
        if (s.trim().equalsIgnoreCase("中国银行")) {
            return "中国";
        }
        return s.replace("中国", "").replace("银行", "");
    }
}
